package com.example.xyh.Controller;

import com.example.xyh.service.OrderListService;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.tags.Tag;
import jakarta.annotation.Resource;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.Optional;

@RestController
@CrossOrigin
@RequestMapping
@Tag(name = "OrderList", description = "OrderListController")
public class OrderListController {
    @Resource
    OrderListService orderListService;

    @Autowired
    public OrderListController(OrderListService orderListService) {
        this.orderListService = orderListService;
    }

    @PostMapping("/ListOrderListByOrderId")
    public List<com.example.xyh.dto.OrderListDto> listOrderListByOrderId(@RequestParam Integer order_id) {
        return orderListService.findByOrderId(order_id);
    }

    @PostMapping("/SaveOrderList")
    public com.example.xyh.dto.OrderListDto saveOrderList(@RequestParam Integer id, Integer item_id, Integer order_id, Integer item_quantity) {
        return orderListService.save(id, item_id, order_id, item_quantity);
    }

    @PostMapping("/ListOrderListByCustomerId")
    public List<com.example.xyh.dto.OrderListDto> listOrderListByCustomerId(@RequestParam Integer customer_id) {
        return orderListService.findByCustomerId(customer_id);
    }
}
